package com.example.demo.util;

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

public class ExcelUtil {

    public static Map<String,String> read(InputStream is) throws Exception {
        Map<String,String> rtnMap = new HashMap<>();
        HSSFWorkbook hssfWorkbook = new HSSFWorkbook(is);
        HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(0);
        for (Row row : hssfSheet) {
            String oldCode = row.getCell(0).getStringCellValue();
            String newCode = row.getCell(1).getStringCellValue();
            rtnMap.put(oldCode,newCode);
        }
        return rtnMap;
    }

}
